<template>
	<view class="container">
		<view class="navTop">
			<view class="navigationbar">
				<view v-for="(item,index) in textlist" :key="index">
					<view class="list_top" :class="{list:current==index}" @click="switch_pages(index)">
						<text :class="{b:current==index}">{{item}}</text>
						<hr :class="{active:current==index}" v-if="current==index" />
					</view>
				</view>
			</view>
		</view>

		<view v-if="current==0">
			<text class="loading-text">
				{{loadingType === 0 ? contentText.contentdown : (loadingType === 1 ? contentText.contentrefresh : contentText.contentnomore)}}
			</text>
			<view v-for="(item,index) in dataList" :key="index" :class="{info_pre:checkbox==true}">
				<view class="kk" :class="{info_pre_false:checkbox==false}" @click="informationDetails(item)">
					<view class="image">
						<image src="/static/image/xianxi.png" mode="aspectFit"></image>
					</view>
					<view class="information">
						<text>{{item.content}}</text>
						<br>
						<text>{{item.sendTime}}</text>
					</view>
					<view class="dot"></view>
				</view>
				<view class="data">
					<checkbox v-if="checkbox==true" :value="item.messageId" :checked="item.checked"
						@click="change(item)" />
				</view>
			</view>
			<view class="blank">
				<!-- 				<input class="input" type="text" v-model="text" placeholder="请输入你要发送得消息"></input>
				<button class="button" @click="sendMessage()">发送</button> -->
			</view>
		</view>
		<view v-if="current==1">
			<text class="loading-text">
				{{readloadingType === 0 ? readcontentText.contentdown : (readloadingType === 1 ? readcontentText.contentrefresh : readcontentText.contentnomore)}}
			</text>
			<view v-for="(item,index) in readInformation" :key="index" class="read" @click="informationDetails(item)">
				<view class="image">
					<image src="/static/image/xianxi.png" mode="aspectFit"></image>
				</view>
				<view class="information">
					<text>{{item.content}}</text>
					<br>
					<text>{{item.sendTime}}</text>
				</view>
			</view>
			<view class="blank">
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// content: '',
				hide: false, //是否隐藏 true为隐藏
				testJson: [],
				userId: '',
				buttons_0: '', //多选、取消按钮
				buttons_1: '', //已读按钮
				buttons_2: '', //全选、全不选
				textlist: ['未读信息', '已读信息'],
				current: 0, //用来判断已读信息跟未读信息 如：0/未读，1/已读
				checkbox: false, //显示选择状态 true为显示
				dataList: [], //未读信息
				unreadScrollTop: '', //未读信息页面的滚动值
				readScrollTop: '', //已读信息页面的滚动值
				readInformation: [], //已读信息
				Information: [],
				state: true, //状态 true:未读 false:已读
				executeOnce: true, //点击已读信息只执行一次
				jurisdiction: false,
				messageId: [],
				returnValue: false, //信息详情返回来的值
				unreadPages: 0, //未读页数
				readPages: 0,
				/* 上拉刷新 */
				loadingType: 0,
				contentText: {
					contentdown: "上拉显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多数据了"
				},
				readloadingType: 0,
				readcontentText: {
					contentdown: "上拉显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多数据了"
				},
			}
		},
		//隐藏页面执行
		onHide() {
			if (this.dataList == null) {
				this.dataList = []
			}
			this.hide = true,
				this.loadingType = 0
			this.readloadingType = 0
			// this.selectAll()
			// #ifdef APP-PLUS
			var currentWebview = this.$mp.page.$getAppWebview();
			var tn = currentWebview.getStyle().titleNView;
			var text = tn.buttons[0].text;
			if (text == '取消') {
				this.title_0()
				this.checkbox = !this.checkbox
				this.jurisdiction = true
			}
			// #endif
			for (var i = 0; i < this.dataList.length; i++) {
				this.dataList[i].checked = false;
			}
			this.messageId.splice(0, this.messageId.length); //清空数组
			// console.log(this.dataList, this.messageId)

		},
		onLoad() {

			this.getunreadPages()
			// this.onSocketMessage()
		},
		onShow() {
			this.onSocketMessage()
			if (this.messageId != 0) {

			}
			console.log(this.loadingType)
			//监听未读信息读取过后传回来的值
			uni.$on("planAdd", res => {
				this.returnValue = res.returnValue
				this.hide = res.hide
				if (this.current == 0) {
					console.log(res.messageId);
					for (let i = 0; i < this.dataList.length; i++) {
						if (this.dataList[i].messageId == res.messageId) {
							this.dataList.splice(i, 1);
						}
					}
				}
				// 清除监听
				uni.$off('planAdd');
			})
			//监听信息下标
			this.getUser()
			//从信息页面返回后跳回上次页面的滚动值的长度
			if (this.returnValue == true) {
				uni.getStorage({
					key: "newsTop",
					success: (res) => {
						console.log(res.data);
						var timer = setTimeout(() => {
							uni.pageScrollTo({
								scrollTop: res.data, //距离页面顶部的距离
								duration: 0
							});
							clearTimeout(timer);
						}, 10)
					},
				})
			} else if (this.returnValue == false) {
				uni.getStorage({
					key: "unreadTop",
					success: (res) => {
						console.log(res.data);
						var timer = setTimeout(() => {
							uni.pageScrollTo({
								scrollTop: res.data, //距离页面顶部的距离
								duration: 0
							});
							clearTimeout(timer);
						}, 10)
					},
				})
			}
			console.log(this.hide)
			if (this.hide == true) {
				this.getunreadPages()
			}
			this.returnValue = false
			this.hide = false
		},
		/* 顶部按钮 */
		onNavigationBarButtonTap(e) {
			if (this.current == 0) { //未读页面顶部按钮
				if (e.index == 0) {
					if (this.dataList == null) {
						this.dataList = []
					}
					if (this.dataList.length != 0) {
						console.log("0按钮")
						this.checkbox = !this.checkbox
						this.jurisdiction = true
						this.title_0()
					} else {
						console.log("0按钮")
						uni.showToast({
							title: '没有数据无法多选',
							duration: 2000,
							icon: 'none'
						});
					}
				} else if (e.index == 1) {
					console.log("1按钮")
					if (this.checkbox == true) {
						this.title_1()
					}
				} else if (e.index == 2) {
					console.log("2按钮")
					if (this.checkbox == true) {
						this.loadingType = 0
						this.title_2()
					}
				}
			} else if (this.current == 1) { //已读页面顶部按钮
				console.log("已读信息")
			}
		},
		//上拉刷新
		onPullDownRefresh() {
			//开启刷新
			uni.startPullDownRefresh();
			//加载列表
			this.getMoreListInfo()
			//关闭刷新
			uni.stopPullDownRefresh();
		},
		// scrollTop是data中定义的变量，可以将页面的滚动值赋值保存下来。
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
			if (this.current == 0) { //未读
				this.unreadScrollTop = e.scrollTop;
			} else if (this.current == 1) { //已读 
				this.readScrollTop = e.scrollTop;

			}
		},
		methods: {
			//全不选变全选
			selectAll() {
				// #ifdef APP-PLUS
				var currentWebview = this.$mp.page.$getAppWebview();
				var tn = currentWebview.getStyle().titleNView;
				var text = tn.buttons[1].text;
				if (text == '全不选') {
					tn.buttons[1].text = "全选";
					currentWebview.setStyle({
						titleNView: tn
					});
				}
				// #endif
			},
			//	打开成功监听服务器返回的消息
			onSocketMessage() {
				uni.onSocketMessage(res => {
					const data = JSON.parse(res.data)
					if (data.code == "99") {
						getApp().globalData.getSocketMsg(res.data);
						if (data.msgType == "sys.notify") {
							this.getunreadPages()
							this.title_recovery() //恢复多选按钮
							this.messageId.splice(0, this.messageId.length); //清空数组
							this.getUser()
							this.checkbox = false
							this.loadingType = 0
							this.readloadingType = 0
						}
					}
				});
			},
			/*已读按钮*/
			async title_2() {
				const res = await this.$myRequest({
					url: '/api-msg/messages/read',
					method: "post",
					data: this.messageId,
				})
				console.log(res)
				if (res.success == true) {
					this.getUser()
					this.getunreadPages()
					this.checkbox = false
					uni.showToast({
						title: '已读取' + this.messageId.length + '条',
						duration: 2000
					});
					// 按钮文字的改变所需
					// #ifdef APP-PLUS
					var currentWebview = this.$mp.page.$getAppWebview();
					var tn = currentWebview.getStyle().titleNView;
					var text = tn.buttons[0].text;
					if (text == '多选') {
						this.cartStatus = true;
						tn.buttons[0].text = '取消';
						currentWebview.setStyle({
							titleNView: tn
						});
					} else if (text == '取消') {
						this.checked = false
						this.cartStatus = false;
						tn.buttons[0].text = '多选';
						currentWebview.setStyle({
							titleNView: tn
						});
					}
					var text1 = tn.buttons[1].text;
					if (text1 == '') {
						this.cartStatus = true;
						tn.buttons[1].text = '全选';
						currentWebview.setStyle({
							titleNView: tn
						});
					} else if (text1 == '全选' || text1 == '全不选') {
						this.cartStatus = false;
						tn.buttons[1].text = '';
						currentWebview.setStyle({
							titleNView: tn
						});
					}
					var text2 = tn.buttons[2].text;
					if (text2 == '') {
						this.cartStatus = true;
						tn.buttons[2].text = '已读';
						currentWebview.setStyle({
							titleNView: tn
						});
					} else if (text2 == '已读') {
						this.cartStatus = false;
						tn.buttons[2].text = '';
						currentWebview.setStyle({
							titleNView: tn
						});
					}
					this.getreadPages()
					// #endif
				}
			},
			title_recovery() {
				// 按钮文字的改变所需
				// #ifdef APP-PLUS
				var currentWebview = this.$mp.page.$getAppWebview();
				var tn = currentWebview.getStyle().titleNView;
				var text = tn.buttons[0].text;
				this.checked = false
				this.cartStatus = false;
				tn.buttons[0].text = '多选';
				currentWebview.setStyle({
					titleNView: tn
				});
				var text1 = tn.buttons[1].text;
				this.cartStatus = false;
				tn.buttons[1].text = '';
				currentWebview.setStyle({
					titleNView: tn
				});

				var text2 = tn.buttons[2].text;
				this.cartStatus = false;
				tn.buttons[2].text = '';
				currentWebview.setStyle({
					titleNView: tn
				});
				this.getreadPages()
				// #endif
			},
			//点击已读信息按钮是获取顶部按钮的状态
			title() {
				// #ifdef APP-PLUS
				var currentWebview = this.$mp.page.$getAppWebview();
				var tn = currentWebview.getStyle().titleNView;
				this.buttons_0 = tn.buttons[0].text;
				this.buttons_1 = tn.buttons[1].text;
				this.buttons_2 = tn.buttons[2].text;
				console.log(this.buttons_0, this.buttons_1, this.buttons_2)
				// 按钮文字的改变所需

				// #endif
			},
			title_unread_None() {
				// #ifdef APP-PLUS
				var currentWebview = this.$mp.page.$getAppWebview();
				var tn = currentWebview.getStyle().titleNView;
				tn.buttons[0].text = this.buttons_0;
				tn.buttons[1].text = this.buttons_1;
				tn.buttons[2].text = this.buttons_2;
				currentWebview.setStyle({
					titleNView: tn
				});
				// #endif
			},
			//未读切换到已读(全选、全不选),已读按钮消失(多选,取消)按钮变成多选
			title_0_None() {
				// #ifdef APP-PLUS
				var currentWebview = this.$mp.page.$getAppWebview();
				var tn = currentWebview.getStyle().titleNView;
				if (this.current == 1) {
					var text = tn.buttons[0].text;
					if (text == '取消' || text == '多选') {
						this.checked = false
						this.cartStatus = false;
						tn.buttons[0].text = '';
						currentWebview.setStyle({
							titleNView: tn
						});
						// this.messageId.splice(0, this.messageId.length); //清空数组
					}
				}
				if (this.jurisdiction == true) {
					var text = tn.buttons[0].text;
					if (text == '取消' || text == '多选') {
						this.checked = false
						this.cartStatus = false;
						tn.buttons[0].text = '多选';
						currentWebview.setStyle({
							titleNView: tn
						});
						this.messageId.splice(0, this.messageId.length); //清空数组
					}
					var text1 = tn.buttons[1].text;
					if (text1 == '全选' || text1 == '全不选') {
						this.cartStatus = false;
						tn.buttons[1].text = '';
						currentWebview.setStyle({
							titleNView: tn
						});
					}
					var text2 = tn.buttons[2].text;
					if (text2 == '已读') {
						this.cartStatus = false;
						tn.buttons[2].text = '';
						currentWebview.setStyle({
							titleNView: tn
						});
					}
				}
				// #endif
			},
			async selectAll() {
				const res = await this.$myRequest({
					url: '/api-msg/messages/',
					method: "get",
					data: {
						isReaded: 0,
						pageSize: this.total,
					}
				})
				if (res.success == true) {
					this.dataList = res.data.data
					// console.log(this.dataList,"dd")
					if (this.dataList != null) {
						for (let i = 0; i < this.dataList.length; i++) {
							this.$set(this.dataList[i], 'checked', false)
						}
					}
				}
			},
			/*全选按钮*/
			async title_1() {
				uni.showLoading({
				    title: '加载中'
				});
				const res = await this.$myRequest({
					url: '/api-msg/messages/',
					method: "get",
					data: {
						isReaded: 0,
						pageSize: this.total,
					}
				})
				if (res.success == true) {
					this.dataList = res.data.data
					if (this.dataList != null) {
						for (let i = 0; i < this.dataList.length; i++) {
							this.$set(this.dataList[i], 'checked', false)
						}
					}
					this.loadingType = 2;
					// #ifdef APP-PLUS
					var currentWebview = this.$mp.page.$getAppWebview();
					var tn = currentWebview.getStyle().titleNView;
					var text = tn.buttons[1].text;
					if (text == '全选') {
						this.cartStatus = true;
						tn.buttons[1].text = '全不选';
						tn.buttons[1].width = "80px",
							currentWebview.setStyle({
								titleNView: tn
							});
						for (let i = 0; i < this.dataList.length; i++) {
							this.$set(this.dataList[i], 'checked', true)
						}
						for (let i = 0; i < this.dataList.length; i++) {
							this.messageId[i] = this.dataList[i].messageId
						}
						uni.showToast({
							title: '已选择' + this.messageId.length + '条',
							duration: 2000
						});
						console.log('全选', this.dataList, this.messageId)
					} else if (text == '全不选') {
						this.cartStatus = false;
						tn.buttons[1].text = '全选';
						tn.buttons[1].width = "60px",
							currentWebview.setStyle({
								titleNView: tn
							});
						this.messageId.splice(0, this.messageId.length); //清空数组
						for (let i = 0; i < this.dataList.length; i++) {
							this.$set(this.dataList[i], 'checked', false)
						}
						console.log('全不选', this.dataList, this.messageId)
					}
					// #endif
				}
				uni.hideLoading();//隐藏 loading 提示框。
			},
			/*选择按钮 */
			change(dataList) {
				dataList.checked = !dataList.checked
				if (dataList.checked == true) { //选择
					this.messageId = this.messageId.concat(dataList.messageId)
					if (this.messageId.length == this.dataList.length) { //长度一样全选变为全不选
						this.title_1_None()
					}
					console.log('已选择', this.dataList, this.messageId)
				} else if (dataList.checked == false) { //取消选择
					for (let i = 0; i < this.dataList.length; i++) {
						if (this.messageId[i] == dataList.messageId) {
							this.messageId.splice(i, 1);
						}
					}
					if (this.messageId.length - 1 == 0) {
						this.title_1_selectAll()
					} else if (this.messageId.length != this.dataList.length) {
						this.title_1_selectAll()
					}
					console.log('取消选择', this.dataList, this.messageId)
				}
			},
			/*
			 * 1、点击全不选按钮变成全选
			 * 2、this.messageId.length - 1 == 0
			 * 3、this.messageId.length != this.dataList.length
			 */
			title_1_selectAll() {
				// #ifdef APP-PLUS
				var currentWebview = this.$mp.page.$getAppWebview();
				var tn = currentWebview.getStyle().titleNView;
				var text = tn.buttons[1].text;
				if (text == '全不选') {
					this.cartStatus = false;
					tn.buttons[1].text = '全选';
					tn.buttons[1].width = "60px",
						currentWebview.setStyle({
							titleNView: tn
						});
				}
				// #endif
			},
			title_1_None() { //this.messageId.length == this.dataList.length 全选变成全不选
				// 按钮文字的改变所需
				// #ifdef APP-PLUS
				var currentWebview = this.$mp.page.$getAppWebview();
				var tn = currentWebview.getStyle().titleNView;
				var text = tn.buttons[1].text;
				if (text == '全选') {
					this.cartStatus = true;
					tn.buttons[1].text = '全不选';
					tn.buttons[1].width = "80px",
						currentWebview.setStyle({
							titleNView: tn
						});
				}
				// #endif
			},
			/*多选按钮 */
			title_0() {
				// #ifdef APP-PLUS
				var currentWebview = this.$mp.page.$getAppWebview();
				var tn = currentWebview.getStyle().titleNView;
				var text = tn.buttons[0].text;
				if (this.jurisdiction == true) {
					// 按钮文字的改变所需
					if (text == '多选') {
						this.cartStatus = true;
						tn.buttons[0].text = '取消';
						currentWebview.setStyle({
							titleNView: tn
						});
					} else if (text == '取消') {
						this.checked = false
						this.cartStatus = false;
						tn.buttons[0].text = '多选';
						currentWebview.setStyle({
							titleNView: tn
						});
						this.messageId.splice(0, this.messageId.length); //清空数组
						//遍历循环this.dataList数组加上checked字段值为false
						for (let i = 0; i < this.dataList.length; i++) {
							this.dataList[i].checked = false
						}
						// console.log('取消', this.dataList, this.messageId)
					}
					var text1 = tn.buttons[1].text;
					if (text1 == '') {
						this.cartStatus = true;
						tn.buttons[1].text = '全选';
						currentWebview.setStyle({
							titleNView: tn
						});
					} else if (text1 == '全选' || text1 == '全不选') {
						this.cartStatus = false;
						tn.buttons[1].text = '';
						currentWebview.setStyle({
							titleNView: tn
						});
					}
					var text2 = tn.buttons[2].text;
					if (text2 == '') {
						this.cartStatus = true;
						tn.buttons[2].text = '已读';
						currentWebview.setStyle({
							titleNView: tn
						});
					} else if (text2 == '已读') {
						this.cartStatus = false;
						tn.buttons[2].text = '';
						currentWebview.setStyle({
							titleNView: tn
						});
					}
				}
				// #endif
			},
			/*信息下标*/
			async unreadQuantity() {
				const res = await this.$myRequest({
					url: '/api-msg/messages/',
					method: "get",
					data: {
						isReaded: 0,
					}
				})
				if (res.success == true) {
					this.total = res.data.totalSize

					var quantity
					if (this.total == 0) {
						uni.removeTabBarBadge({
							index: 1,
						})
					} else if (this.total >= 99) {
						quantity = "99+"
					} else {
						quantity = this.total
						quantity = quantity.toString()
					}
					uni.setTabBarBadge({
						index: 1,
						text: quantity,
					})
				}
			},
			/*获取user、存在去信息下标*/
			async getUser() { //读取客户信息
				const res = await this
					.$myRequest({
						url: '/api-portal/currentUser'
					})
				if (res.success == true) { //如果读取信息成功
					this.user = res.body.currentUser;
					this.userId = res.body.currentUser.id;
					this.unreadQuantity()
				} else if (res.success == false) { //如果读取信息成功
					uni.removeTabBarBadge({
						index: 1,
					})
				}
			},

			/* 跳转页面 */
			informationDetails(dataList) {
				if (this.current == 0) {
					if (this.checkbox == true) {
						dataList.checked = !dataList.checked
						if (dataList.checked == true) { //选择
							this.messageId = this.messageId.concat(dataList.messageId)
							if (this.messageId.length == this.dataList.length) { //长度一样全选变为全不选
								this.title_1_None()
							}
							console.log('已选择', this.dataList, this.messageId)
						} else if (dataList.checked == false) { //取消选择
							for (let i = 0; i < this.dataList.length; i++) {
								if (this.messageId[i] == dataList.messageId) {
									this.messageId.splice(i, 1);
								}
							}
							if (this.messageId.length - 1 == 0) {
								this.title_1_selectAll()
							} else if (this.messageId.length != this.dataList.length) {
								this.title_1_selectAll()
							}
							console.log('取消选择', this.dataList, this.messageId)
						}
					} else {
						uni.navigateTo({
							url: '/pages/news/informationDetails?content=' + dataList.content + '&messageId=' +
								dataList
								.messageId
						})
						uni.setStorage({
							key: "unreadTop",
							data: this.scrollTop
						})
						if (this.current == 0) {
							this.getreadPages()
						}
					}

				} else if (this.current == 1) {
					uni.navigateTo({
						url: '/pages/news/informationDetails?content=' + dataList.content + '&messageId=' +
							dataList
							.messageId
					})
					uni.setStorage({
						key: "unreadTop",
						data: this.scrollTop
					})
				}

			},
			//获取未读信息页数
			async getunreadPages() {
				const res = await this.$myRequest({
					url: '/api-msg/messages/',
					method: "get",
					data: {
						isReaded: 0,
					}
				})
				if (res.success == true) {
					this.unreadPages = res.data.totalPage
					this.news()
				}
			},
			/*未读列表*/
			async news() {
				const res = await this.$myRequest({
					url: '/api-msg/messages/',
					method: "get",
					data: {
						pageNumber: this.unreadPages,
						isReaded: 0,
					}
				})
				if (res.success == true) {
					this.dataList = res.data.data
					// console.log(this.dataList,"dd")
					if (this.dataList != null) {
						for (let i = 0; i < this.dataList.length; i++) {
							this.$set(this.dataList[i], 'checked', false)
						}
					} else if (this.dataList == null) {
						this.loadingType = 2;
					}
					setTimeout(() => {
						uni.pageScrollTo({
							scrollTop: 999999999,
							duration: 0
						});
					}, 50);
				}
			},
			//获取已读信息页数
			async getreadPages() {
				const res = await this.$myRequest({
					url: '/api-msg/messages/',
					method: "get",
					data: {
						isReaded: 1,
					}
				})
				if (res.success == true) {
					this.readPages = res.data.totalPage
					this.read()
					// console.log(this.readPages)
				}
			},
			/*已读列表*/
			async read() {
				// console.log(this.readPages)
				const res = await this.$myRequest({
					url: '/api-msg/messages/',
					method: "get",
					data: {
						pageNumber: this.readPages,
						// pageNumber: 3,
						isReaded: 1,
					}
				})
				if (res.success == true) {
					// this.readInformation = this.readInformation.concat(res.data.data)
					this.readInformation = res.data.data
					if (this.readInformation == null) {
						this.readloadingType = 2;
					}
					setTimeout(() => {
						uni.pageScrollTo({
							scrollTop: 9999999999,
							duration: 0
						});
					}, 50);
				}
			},
			/* 未读、已读选择 */
			switch_pages(index) {
				this.current = index;
				if (this.current == 0) {
					console.log("未读1")
					console.log('switch_pages未读', this.dataList, this.messageId)
					if (this.state == false) {
						this.title_unread_None()
					}
					this.state = true
					uni.setStorage({ //记住未读页面的滚动值
						key: "unreadTop",
						data: this.unreadScrollTop
					})
					uni.getStorage({ //跳回上次未读页面的滚动值
						key: "unreadTop",
						success: (res) => {
							console.log(res.data);
							var timer = setTimeout(() => {
								uni.pageScrollTo({
									scrollTop: res.data, //距离页面顶部的距离
									duration: 0
								});
								clearTimeout(timer);
							}, 10)
						},
					})
				} else if (this.current == 1) {
					if (this.state == true) {
						this.title()
					}
					this.state = false
					this.title_0_None()
					uni.setStorage({ //记住已读页面的滚动值
						key: "readTop",
						data: this.readScrollTop
					})
					uni.getStorage({ //跳回上次已读页面的滚动值
						key: "readTop",
						success: (res) => {
							console.log(res.data);
							var timer = setTimeout(() => {
								uni.pageScrollTo({
									scrollTop: res.data, //距离页面顶部的距离
									duration: 0
								});
								clearTimeout(timer);
							}, 10)
						},
					})
					// console.log("已读")
					// this.title_0_None()
					if (this.executeOnce == true) {
						//点击已读选项加载
						this.getreadPages()
						this.executeOnce = false
					}
				}
			},
			/* 上拉加载未读列表 */
			async getMoreListInfo() {
				if (this.current == 0) {
					// console.log( "未读信息",this.unreadPages)
					this.unreadPages--
					if (this.loadingType != 0) {
						return false; //loadingType!=0;直接返回
					}
					this.loadingType = 1;
					// uni.showNavigationBarLoading();
					const res = await this.$myRequest({
						url: '/api-msg/messages/',
						method: "get",
						data: {
							pageNumber: this.unreadPages,
							isReaded: 0,
						},
					})
					if (res.success == true) {
						if (this.dataList != null) {
							if (this.dataList.length == res.data.totalSize) { //当之前的数据长度等于count时跳出函数，不继续执行下面语句
								this.loadingType = 2;
								// uni.hideNavigationBarLoading(); //关闭加载动画
								return false;
							}
							//清空this.Information数组
							this.Information.splice(0, this.Information.length);
							//把this.dataList数组赋给this.Information
							this.Information = this.Information.concat(this.dataList)
							//清空this.dataList数组
							this.dataList.splice(0, this.dataList.length);
							//把res.data.data赋给this.dataList数组的最前面
							this.dataList = this.dataList.concat(res.data.data)
							//遍历循环this.dataList数组加上checked字段值为false
							for (let i = 0; i < this.dataList.length; i++) {
								this.$set(this.dataList[i], 'checked', false)
							}
							console.log('已加载', this.dataList)
							//把之前的数组接到末尾
							this.dataList = this.dataList.concat(this.Information)
						}
						this.loadingType = 0; //将loadingType归0重置
						if (this.messageId.length != this.dataList.length) {
							this.title_1_selectAll()
						}
					}
					// uni.hideNavigationBarLoading(); //关闭加载动画
				} else if (this.current == 1) {
					this.readPages--
					console.log(this.readloadingType)
					if (this.readloadingType != 0) {
						return false; //loadingType!=0;直接返回
					}
					console.log(this.readInformation.length, "已读1信息", this.readPages)
					this.readloadingType = 1;
					// uni.showNavigationBarLoading();
					const res = await this.$myRequest({
						url: '/api-msg/messages/',
						method: "get",
						data: {
							pageNumber: this.readPages,
							isReaded: 1,
						},
					})
					// console.log(res.success)
					if (res.success == true) {
						if (this.readInformation != null) {
							// console.log( "历史接口1", res.data.totalSize, this.readPages)
							if (this.readInformation.length == res.data.totalSize) { //当之前的数据长度等于count时跳出函数，不继续执行下面语句
								this.readloadingType = 2;
								// uni.hideNavigationBarLoading(); //关闭加载动画
								console.log("没有数据了")
								return false;
							}
							this.Information.splice(0, this.Information.length); //清空数组
							this.Information = this.Information.concat(this.readInformation)
							this.readInformation.splice(0, this.readInformation.length); //清空数组
							this.readInformation = this.readInformation.concat(res.data.data)
							this.readInformation = this.readInformation.concat(this.Information)
						}
						this.readloadingType = 0; //将loadingType归0重置
						// uni.hideNavigationBarLoading(); //关闭加载动画
					}
				}
				//这段代码很重要，不然每次加载历史数据都会跳到顶部
				setTimeout(() => {
					uni.pageScrollTo({
						scrollTop: 1300,
						duration: 0
					});
				}, 50);
			},

		}
	}
</script>

<style lang="scss" scoped>
	.container {
		color: #000000;
	}

	.loading-text {
		height: 50upx;
		line-height: 80upx;
		font-size: 30rpx;

		// margin: 100rpx;
		color: #959595;
		display: flex;
		flex-direction: row;
		justify-content: space-around;
	}

	.data {
		width: 20rpx;
	}

	.info_pre {
		// position: relative;
		margin: 4% 10%;
		justify-content: space-around;
		border-radius: 8px;
		display: flex;
		align-items: center;

		.kk {
			border: 1px solid #e1e1e1;
			box-shadow: 1px 1px 10px #9eaeb5;
			background-color: white;
			border-radius: 8px;
			display: flex;
			align-items: center;
			width: 500rpx;

			.dot {
				margin: 0 10rpx 40rpx 0;
				height: 20rpx;
				width: 20rpx;
				border-radius: 25px;
				background-color: #109EF8;
			}

			.image {
				width: 20%;
				height: 80rpx;
				display: inline-block;
				vertical-align: middle;
				align-items: center;

				image {
					width: 100%;
					height: 80rpx;
				}
			}

			.information {
				position: relative;
				width: 75%;
				display: block;
				padding: 2% 0;
				font-size: 30rpx;

				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;

				text:nth-child(1) {
					width: 100%;
				}

				text:nth-child(3) {
					width: 100%;
					font-size: 28rpx;

					color: #959595;
				}
			}
		}
	}

	.info_pre_false {
		margin: 4% 10%;
		justify-content: space-around;
		border-radius: 8px;
		display: flex;
		align-items: center;
		border: 1px solid #e1e1e1;
		box-shadow: 1px 1px 10px #9eaeb5;
		background-color: white;

		.dot {
			margin: 0 10rpx 40rpx 0;
			height: 20rpx;
			width: 20rpx;
			border-radius: 25px;
			background-color: #109EF8;
		}

		.image {
			width: 20%;
			height: 80rpx;
			display: inline-block;
			vertical-align: middle;
			align-items: center;

			image {
				width: 100%;
				height: 80rpx;
			}
		}

		.information {
			width: 75%;
			display: block;
			padding: 2% 0;
			font-size: 30rpx;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;

			text:nth-child(1) {
				width: 100%;
			}

			text:nth-child(3) {
				width: 100%;
				font-size: 28rpx;

				color: #959595;
			}
		}
	}

	//已读
	.read {
		margin: 4% 10%;
		border: 1px solid #e1e1e1;
		box-shadow: 1px 1px 10px #9eaeb5;
		background-color: white;
		border-radius: 8px;
		display: flex;
		align-items: center;

		.dot {
			margin: 0 10rpx 40rpx 0;
			height: 20rpx;
			width: 20rpx;
			border-radius: 25px;
			background-color: #109EF8;
		}

		.image {
			width: 20%;
			height: 80rpx;
			display: inline-block;
			vertical-align: middle;
			align-items: center;

			image {
				width: 100%;
				height: 80rpx;
			}
		}

		.information {
			width: 78%;
			display: block;
			padding: 2% 0;
			font-size: 30rpx;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;

			text:nth-child(1) {
				color: #000000;
				width: 100%;
			}

			text:nth-child(3) {
				width: 100%;
				font-size: 28rpx;

				color: #959595;
			}
		}
	}

	.blank {
		height: 200rpx;

		.input {
			width: 100%;
			height: 100rpx;
		}
	}

	.navTop {
		height: 69rpx;

		.navigationbar {
			z-index: 99;
			width: 100%;
			height: 69rpx;
			background: #FFFFFF;
			// display: flex;
			// justify-content: space-around;
			line-height: 69rpx;
			text-align: center;
			padding-bottom: 3px;
			position: fixed;

			.list_top {
				width: 50%;
				// padding-bottom: 3px;
				float: left;
				// position: relative;

				hr {
					// position: absolute;
					width: 100%;
					border: none;
					height: 8rpx;
					bottom: 0;
					background-color: #109EF8;
				}

				.active {
					width: 100%;
					border: none;
					height: 8rpx;
					position: relative;
					bottom: 0;
					// background-color: #109EF8;
				}

				b {
					color: #959595;
				}

				.b {
					color: #000000;
				}
			}

			.list {
				height: 20rpx;
			}
		}
	}
</style>
